package com.itheima.reggie.common;

import org.springframework.context.annotation.Configuration;

/**
 * 基于ThreadLocal封装工具类,用户设置和获取当前登录用户id
 */

public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    /**
     * 设置值
     * @param id
     */
   public static void setCurrentId(Long id){
    threadLocal.set(id);
   }

    /**
     * 获取值
     * @return
     */
    public static Long getCurrentId(){
       return threadLocal.get();
    }

    /**
     * 释放数据
     */
    public static void release(){
        threadLocal.remove();
    }

}
